package service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import dao.UserMapper;
import entity.User;
import entity.UserExample;
import entity.UserExample.Criteria;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	UserMapper userMapper;

	@Override
	public PageInfo<User> userQuery(int pageNum,int pageSize) {
		UserExample example=new UserExample();
		example.setOrderByClause("uid desc");
		List<User> list = userMapper.selectByExample(example);
		PageHelper.startPage(pageNum, pageSize);
		
		PageInfo<User> PageInfo=new PageInfo<User>(list);
		return PageInfo;
	}
	@Override
	public List<User> selectAll() {
		UserExample example=new UserExample();
		Criteria criteria = example.createCriteria();
		List<User> userList = userMapper.selectByExample(example);
		return userList;
	}
	@Override
	public int del(int uid) {
		return userMapper.deleteByPrimaryKey(uid);
	}



	
}
